package cn.tedu.spring.dibase;

import cn.tedu.spring.iocxml.User;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ruoLi
 */
public class BookTest {
    @Test
    public void SetTest(){
        //原生set
        Book book=new Book();
        book.setBookAuthor("凡尔纳");
        book.setBookName("海底两万里");
        System.out.println(book);
    }

    @Test
    public void ConsTest(){
        //原生构造器
        Book book=new Book("神雕侠侣","金庸");
        System.out.println(book);
    }

    @Test
    public void SpringTest(){
        //set注入
        ApplicationContext context = new ClassPathXmlApplicationContext("bean-di.xml");
        Book book = context.getBean("book",Book.class);
        System.out.println(book);
    }

    @Test
    public void SpringConsTest(){
        //构造器注入
        ApplicationContext context = new ClassPathXmlApplicationContext("bean-di.xml");
        Book book = context.getBean("bookCons", Book.class);
        System.out.println(book);
    }

}
